
Ext.define('IAG.view.logs.LogsView' ,{
    extend: 'Ext.grid.Panel',
    alias : 'widget.logs',

    layout: 'fit',
    autoShow: true,

    store: 'LogsStore',

    columns: [
              {header: 'Db Id',  dataIndex: 'id',  flex: 1, hidden:true},
              {header: 'Group Id',  dataIndex: 'timeMillis',  flex: 1, hidden: true},
              {header: 'Feed Tag', dataIndex: 'feedTag', flex: 1, tooltip:"aaaaa"},
              {
            	  header: 'Status',  
            	  dataIndex: 'importStatus',  
            	  width: 50,
            	  align: "center",
            	  renderer: function(value) {
            		  if (value < 1)
            			  return Ext.String.format('<img src="{0}/not_ok_ico.gif" />', iag_constants.images_path);
            		  else
            			  return Ext.String.format('<img src="{0}/ok_ico.gif" />', iag_constants.images_path);
                  }

              },
              {header: 'Url',  dataIndex: 'url',  flex: 1},
              {header: 'Feed Update Time',  dataIndex: 'timestamp',  flex: 1, hidden: true},
              {header: 'Local Url',  dataIndex: 'localUrl',  flex: 1},
              {header: 'Zipped',  dataIndex: 'zipped',  flex: 1},
              {header: 'Description',  dataIndex: 'description',  flex: 1, hidden: true},
              {header: 'Iati standard',  dataIndex: 'standard',  flex: 1, hidden: true},
              {
            	  xtype: 'actioncolumn',
            	  width:30,
            	  items: [{
            		  icon: iag_constants.images_path+'/ico_export.gif',  
            		  tooltip: 'Reload',
            		  handler: function(grid, rowIndex, colIndex) {
            			  	var rec 	= grid.getStore().getAt(rowIndex);
            			  	myLogsController.reloadFeed(rec.get('id'));
            		  		}
            		  } 
            	  ]
//        		  renderer: function (value, metadata, record) {
//        			  if ( record.get('importStatus') < 1 )
//        				  return ;
//        			  else
//        				  return "OK";
//        		  }
              }
              ],
	  buttons:[
	           {
	        	   text: 'Stop',
	        	   iconCls: 'stopImportButton',
	        	   action: 'stopImport'
	           },
	           
	           {
	        	   text: 'Reload Failed',
	        	   iconCls: 'reloadFailedButton',
	        	   action: 'reloadFailedImport'
	           },
	           {
	        	   text: 'Refresh',
	        	   action: 'reloadLogs'
	           }
	           ],
	     viewConfig: {
	           getRowClass: function(rec, idx, rowPrms, ds) {
	                return rec.data.importStatus < 1 ? 'failedLogRow' : '';
	            }
	     }

    
});

